CISC 1110                       Lab 5              

 

     Write a program which issues a prompt to enter an integer value and then reads in that integer value into a variable called number and prints it the value of number on the screen.

 

      Then use an if-else to ask whether the number read in is larger than 5, and print an answer in each case:

·        If the number typed is larger than 5, print a message saying it is larger than 5.

·        But, if the number typed in is NOT larger than 5 (else clause), send a message to cout saying the number typed in is not larger than 5.


Once you have this program compiled, run it three times, entering the following data values:

a.       Enter the value 10 when you are prompted to type.

b.      Repeat for the value 2

c.       Repeat for the value 5

 

             After you run the program on these values of number, enclose the statements above in a while loop that continues until you enter some phony value (like 0 or -1).

The loop will read in a value and then test it in the if/else statement. Be sure to use a structured read loop, reading the first value ABOVE the loop and each of the remaining values inside the loop at the bottom.

             Test this revised program on the same set of values as above:

a.  Enter the value 10 when you are prompted to type.

b.  Repeat for the value 2

c.  Repeat for the value 5

d.  Finish by entering your phony value.